const { Liquid } = require('liquidjs');
const { devPath } = require('./index');
const fs = require('fs');
exports.engine = new Liquid({
  root: __dirname, // for layouts and partials
  extname: '.liquid',
  relativeReference: false,
  globals: {
    theme_config: JSON.parse(fs.readFileSync(devPath('/config/settings_data.json'), 'utf-8')),
    shop_id_to_letter: 'shopyy',
    oemsaas_client_ipinfo: '{}',
    country: 'CN',
    cdn_url: 'https://cn01-cdn.staticsyy.com',
    oemcart_current_template: 'def',
    'Execution-Time': '1',
    template: 'template',
    is_theme_edit: 1,
    customer_comment_status: 1,
    firewall: false,
    page_ca: '/',
    customerId: 0,
    theme: '',
    storeInfo: {
      id: 47749,
      shop_name: 'OEMSAAS',
      shop_domain: 'shopyy.oemsaas.cn',
      main_domain: '',
      package_id: 4,
      brand_id: 212,
      user_id: 4,
      status: 1,
      loan: 3,
      subscription_status: 0,
      node_hash: 'cn01',
      tbl_hash: '00',
      server_node_id: 1,
      imgcdn_domain: '',
      commission: '1.00',
      commission_status: 0,
      commission_billing_threshold: 50,
      discount_off: '50.00',
      time_zone: 'Etc/UTC',
      client_token: '3ea4456e-6ebf-47b4-861a-d1d79b69cd72',
      starts_at: 0,
      is_ka_cluster: 1,
      ends_at: 1691625599,
      lock_status: 0,
      updated_at: 1661018402,
      created_at: 1627961059,
      bn_code: '',
      https_status: 1,
    },
  },
  fs: {
    readFileSync(file, ext) {
      return fs.readFileSync(file, 'utf-8');
    },
    readFile(file) {
      const temp = fs.readFileSync(file, 'utf-8');
      return temp;
    },
    existsSync() {
      return true;
    },
    exists() {
      return true;
    },
    resolve(root, file, ext) {
      return file;
    },
  },
});
